package toolbar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import aLeSoftware.ModeleGeneral;
import modele.*;

public class ControleurToolBar implements ActionListener {

	private ModeleGeneral mGeneral;

	public ControleurToolBar(ModeleGeneral mg) {
		this.mGeneral = mg;
	}
	
	public ModeleGeneral getmGeneral() {return mGeneral;}
	
	public void actionPerformed(ActionEvent a) {

		
		
		mGeneral.getModDessin().stockFormeTampon();
		
		String source = a.getActionCommand();
		
		if (source == "Cercle") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Cercle");
			mGeneral.getModDessin().setFormeTampon(new Cercle());
		}

		if (source == "Point") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Point");
		}

		if (source == "Segment") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Segment");
			mGeneral.getModDessin().setFormeTampon(new Segment());
		}

		if (source == "Polygone") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Polygone");
			mGeneral.getModDessin().setFormeTampon(new Polygone());
		}
		if (source == "Pinceau") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Pinceau");
			mGeneral.getModDessin().setFormeTampon(new Groupe());
		}
		if (source == "Rectangle") {
			mGeneral.getModDessin().resetSelection();
			mGeneral.setChoixOutils("Rectangle");
			mGeneral.getModDessin().setFormeTampon(new Rectangle());
			
		}

		if (source == "Selection") {
			mGeneral.setChoixOutils("Selection");
		}
		
		if (source == "Deplacement") {
			mGeneral.setChoixOutils("Deplacement");
		}
		
		
		this.mGeneral.updateObservateur();	
	}
}
